package com.geotmt.billingcenter.modules.link.mapper.provider;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Description SQL
 * @Author      yanghanwei
 * @Mail        yanghanwei@geotmt.com
 * @Date        2019/4/16 18:46
 * @Version     v1
 **/
public class LinkProvider {

    private static final Logger logger = LoggerFactory.getLogger(LinkProvider.class);

    /**
     * 根据接口名查询接口id(inner)
     * @param type
     * @return
     */
    public String getInterfaceIdByType(String type){
        StringBuffer sql = new StringBuffer();
        sql.append("SELECT id FROM `t_interface` WHERE interface_name=#{type}");
        logger.info("根据接口名查询接口id(inner),SQL:{}",sql);
        return sql.toString();
    }

    /**
     * 根据接口名查询接口id(outer)
     * @param type
     * @return
     */
    public String getOutInterfaceIdByType(String type){
        StringBuffer sql = new StringBuffer();
        sql.append("SELECT * FROM `t_out_interface` WHERE interface_name=#{type}");
        logger.info("根据接口名查询接口id(outer),SQL:{}",sql);
        return sql.toString();
    }

    /**
     * 根据外部接口查询数据源id
     * @param type
     * @return
     */
    public String getDsIdByIfType(String type){
        StringBuffer sql = new StringBuffer();
        sql.append("SELECT ds_id FROM `t_out_interface` WHERE interface_name=#{type}");
        logger.info("根据外部接口查询数据源id,SQL:{}",sql);
        return sql.toString();
    }
}
